const express = require('express')
const app = express()
const port = 8000
const multer = require('multer')
const path = require('path')
app.use("", express.static('./uploads'))
const storage = multer.diskStorage({
    destination: function (req, file, cb) {
        cb(null, './uploads')
    },
    filename: function (req, file, cb) {
        const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9)

        cb(null, file.fieldname + '-' + uniqueSuffix + path.extname(file.originalname))

    }
})


const upload = multer({ storage: storage })

app.post('/uploadFile', upload.single('falt-data'), (req, res) => {
    res.send(`http://192.168.77.27:8000/${req.file.filename}`)
})
app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`); })